<template>
  <div style="padding: 10px 30px" v-loading="lods">
    <el-radio-group v-model="lpradio" size="mini" style="margin: 10px 0">
      <el-radio-button label="商品管理列表" @click.native="lpalllist(1)"></el-radio-button>
      <el-radio-button label="电商罗盘商品卡列表" @click.native="lpalllist(2)"></el-radio-button>
    </el-radio-group>
    <div class="flex f-between-center">
      <div class="flex">
        <div class="font-size-14">商品创建时间：</div>
        <div v-if="listType == 1">
          <el-radio :disabled="disabled" v-model="radio" v-for="(item, index) in commodityAdminRadiolist" :key="index"
            :label="item.label" @change="getTimes(item, index)">{{ item.name }}</el-radio>
        </div>
        <div v-if="listType == 2">
          <el-radio :disabled="disabled" v-model="radio" v-for="(item, index) in onlineretailers" :key="index"
            :label="item.label" @change="getTimes(item, index)">{{ item.name }}</el-radio>
        </div>
      </div>
      <div>
        <el-popover placement="bottom" trigger="hover">
          <div>
            <el-tag type="danger" size="mini">微信扫一扫联系客服</el-tag>
            <div>
              <img style="border-radius: 20px"
                src="https://wtplugwt.oss-cn-hangzhou.aliyuncs.com/webimages/code/WechatIMG6.jpg" alt="" />
            </div>
          </div>
          <el-button slot="reference" type="primary" size="mini">联系客服</el-button>
        </el-popover>
      </div>
    </div>

    <div style="color: red; font-weight: 900" class="mt-10 flex f-between-center">
      <div style="display: flex">
        <div>清理无流量商品条件：</div>
        <div>满足任一条件即进入待清理无流量商品列表</div>
      </div>
    </div>
    <div style="padding: 20px 200px">
      <el-checkbox v-model="bgnum.radio" label="1" :disabled="disabled">
        <div style="margin-top: -15px" class="flex ml-20 f-start-center">
          <div style="color: black; width: 145px" class="flex f-start-center">
            <span> 清理曝光次数 </span>
            <el-tooltip class="ml-5 mr-10" effect="dark" content="商品卡商品曝光次数" placement="top">
              <img class="ml-10" src="@/assets/images/question-mark.png" style="width: 15px; height: 15px" alt="" />
            </el-tooltip>
            <= </div>
              <input :disabled="disabled" v-model="bgnum.input" type="number"
                style="width: 80px; margin-top: -3px; margin-left: 10px" />
          </div>
      </el-checkbox>
      <el-checkbox v-model="radiomoney.radio" label="2" :disabled="disabled">
        <div style="display: flex; margin-top: -15px; margin-left: 20px">
          <div style="color: black; width: 100px">清理售价位于:</div>
          <input :disabled="disabled" type="number" v-model="radiomoney.input"
            style="width: 100px; margin-top: -4px; margin: 0 10px" />-
          <input :disabled="disabled" type="number" v-model="radiomoney.input2"
            style="width: 100px; margin-top: -4px; margin-left: 10px" />
        </div>
      </el-checkbox>
    </div>
    <div style="padding: 0px 200px">
      <el-checkbox v-model="djnum.radio" label="3" :disabled="disabled">
        <div style="margin-top: -15px" class="flex ml-20 f-start-center">
          <div style="color: black; width: 145px" class="flex f-start-center">
            <span> 清理点击次数 </span>
            <el-tooltip class="ml-5 mr-10" effect="dark" content="用户在抖音、抖音极速版，通过非直播、非短视频页面以商品卡片的样式点击商品的次数"
              placement="top">
              <img class="ml-10" src="@/assets/images/question-mark.png" style="width: 15px; height: 15px" alt="" />
            </el-tooltip>
            <= </div>
              <input :disabled="disabled" v-model="djnum.input" type="number"
                style="width: 80px; margin-top: -3px; margin-left: 10px" />
          </div>
      </el-checkbox>
      <el-checkbox v-model="stock_nums.radio" label="4" :disabled="disabled">
        <div style="display: flex; margin-top: -15px; margin-left: 20px">
          <div style="color: black; width: 100px">总库存位于:</div>
          <input :disabled="disabled" v-model="stock_nums.input" type="number"
            style="width: 100px; margin-top: -4px; margin: 0 10px" />-
          <input :disabled="disabled" v-model="stock_nums.input2" type="number"
            style="width: 100px; margin-top: -4px; margin-left: 10px" />
        </div>
      </el-checkbox>
    </div>
    <div style="padding: 20px 200px">
      <el-checkbox v-model="radiosnum.radio" label="5" :disabled="disabled">
        <div style="margin-top: -15px" class="flex ml-20 f-start-center">
          <div style="color: black; width: 145px" class="flex f-start-center">
            <span> 清理总销量 </span>
            <el-tooltip class="ml-5 mr-10" effect="dark" content="系统识别到的异常订单，销量不累计" placement="top">
              <img class="ml-10" src="@/assets/images/question-mark.png" style="width: 15px; height: 15px" alt="" />
            </el-tooltip>
            <= </div>
              <input :disabled="disabled" type="number" v-model="radiosnum.input"
                style="width: 80px; margin-top: -3px; margin-left: 10px" />
          </div>
      </el-checkbox>
      <el-checkbox v-model="radios" label="6" :disabled="disabled">
        <div style="margin-top: -15px" class="flex ml-20 f-start-center">
          <div style="color: black; width: 145px" class="flex f-start-center">
            <span> 好评率 </span>
            <el-popover placement="top" width="300" trigger="hover">
              <div>
                <div class="font-weight-600">商品好评率指标定义</div>
                <div class="flex f-between-center">
                  <span class="f--1"> 计算公式： </span>
                  <div class="f--2 mt-10">
                    <div>近30天商品好评订单数</div>
                    <div>--------------------------------</div>
                    <div>近30天物流签收订单数</div>
                  </div>
                </div>
                <div class="mt-10 font-weight-600">考核周期</div>
                <div>近30天物流签收订单</div>
                <div>注意：取用户首次评价结果</div>
              </div>
              <img slot="reference" class="mx-5" src="@/assets/images/question-mark.png"
                style="width: 15px; height: 15px" alt="" />
            </el-popover>
            低于:
          </div>
          <input v-model="rainput" :disabled="disabled" type="number"
            style="width: 100px; margin-top: -4px; margin: 0 10px" />
        </div>
      </el-checkbox>
    </div>
    <div class="flex f-start-center font-size-14">
      <span>跳过筛选条件：</span>
      <el-checkbox :disabled="disabled" v-model="radioss" label="" style="color: black">
      </el-checkbox>
      <span class="ml-5"> 保留铺货时间<= </span>
          <input :disabled="disabled" type="number" style="width: 100px; margin: 0 10px" v-model="typeNumber" />
          <div style="">天</div>
          <el-tooltip content="如果满足左方勾选条件,则不清理商品 (下架商品不进入该判断条件)" placement="top">
            <i class="el-icon-warning-outline" style="margin: 0 10px"></i>
          </el-tooltip>
    </div>
    <div class="flex mt-20 f-start-center">
      <div class="font-size-14">筛选无流量商品的商品来源：</div>
      <div>
        <div>
          <el-radio-group v-model="radio2" size="mini" @change="allProducts()" :disabled="disabled">
            <el-radio-button v-for="(item, index) in allProductslist" :label="item" :key="index">
            </el-radio-button>
          </el-radio-group>
        </div>
      </div>
    </div>
    <div style="display: flex; margin-top: 20px; justify-content: space-between">
      <div class="flex font-size-14">
        <div>待清理无流量商品列表：</div>
        <div v-if="lists.length > 0">
          无需清理商品共【{{ lists.length }}】个
        </div>
        <div v-if="lists.length > 0">
          <el-button type="primary" size="mini" class="ml-20" @click="dialogVisibles = true">查看</el-button>
        </div>
      </div>
      <div>
        <el-button type="primary" size="mini" :loading="loading2" @click="bt1()">导入商品ID</el-button>
        <el-button type="primary" size="mini" :loading="loading2" @click="bt2()">{{ btnName }}
        </el-button>

        <el-popover placement="bottom" width="10" trigger="hover" style="margin-left: 10px">
          <div>
            <div>
              <div>
                <el-button size="mini" type="primary" style="width: 100px" @click="bt3()">下架商品</el-button>
              </div>
              <div style="margin-top: 10px">
                <el-button size="mini" type="primary" style="width: 100px" @click="bt4()">下架并删除</el-button>
              </div>
            </div>
          </div>
          <el-button slot="reference" type="danger" size="mini" :loading="loading2">一键清理【{{
            this.multipleSelection.length
            }}】个流量商品</el-button>
        </el-popover>
        <el-popover placement="bottom" width="400" trigger="hover" style="margin-left: 10px">
          <div>
            <div>
              <el-button type="primary" size="mini" @click="copy()">复制</el-button>
              <el-button type="primary" size="mini" @click="goTxt()">导出文本</el-button>
              <el-button type="primary" size="mini" @click="Export()">导出Excel</el-button>
              <el-button type="primary" size="mini" @click="goCsv()">导出CSV</el-button>
            </div>
            <div style="margin-top: 20px">
              <div style="display: flex">
                <div style="margin-right: 20px">配置导出字段</div>
                <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll"
                  @change="handleCheckAllChange">全选</el-checkbox>
              </div>
              <div style="margin: 15px 0"></div>
              <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
                <el-checkbox v-for="(item, index) in cities" :label="item.value" :key="index">{{
                  item.name }}</el-checkbox>
              </el-checkbox-group>
            </div>
          </div>
          <el-button size="mini" :loading="loading2" slot="reference">复制导出</el-button>
        </el-popover>
      </div>
    </div>
    <div style="">
      <el-table v-loading="tableloading" element-loading-text="数据加载中" id="table_excel" :data="tableData"
        tooltip-effect="dark" style="width: 100%" height="700" empty-text="暂无数据"
        @selection-change="handleSelectionChange">
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="index" label="序号" width="120" type="index">
        </el-table-column>
        <el-table-column prop="address" label="图片" width="110px">
          <template slot-scope="scope">
            <el-image style="width: 100px; height: 100px" :src="scope.row.img" :preview-src-list="[scope.row.img]">
            </el-image>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="商品信息" width="500">
          <template slot-scope="scope">
            <div>{{ scope.row.name }}</div>

            <div>ID:{{ scope.row.product_id }}</div>
          </template>
        </el-table-column>

        <el-table-column prop="jg" label="价 格"> </el-table-column>
        <el-table-column prop="stock_num" label="总库存" width=""></el-table-column>
        <el-table-column prop="sell_num" label="总销量" width=""></el-table-column>
        <el-table-column prop="time" label="创建时间" width="150">
        </el-table-column>
        <el-table-column prop="djcs" label="点击次数" width=""></el-table-column>
        <el-table-column prop="dj" label="点击人数" width=""></el-table-column>
        <el-table-column prop="bgcs" label="曝光次数" width=""></el-table-column>
        <el-table-column prop="bg" label="曝光人数" width=""> </el-table-column>
        <el-table-column label="日志" width="">
          <template slot-scope="scope">
            <el-tag type="warning" size="mini" v-if="scope.row.alerts == '已下架'">{{ scope.row.alerts
            }}</el-tag>
            <el-tag type="danger" size="mini" v-if="scope.row.alerts == '已删除'">{{ scope.row.alerts
            }}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="根据商品ID批量搜索商品" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
      <el-tag type="danger">可以输入商品ID(一行一个商品Id)，必须是该店铺的商品才可以</el-tag>
      <textarea style="margin-top: 20px; width: 100%; height: 400px" :rows="2" placeholder="一行一个商品ID"
        v-model="textarea"></textarea>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="bt1Vis()">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog title="无需清理商品" :visible.sync="dialogVisibles" width="50%" :before-close="handleCloses">
      <div>
        <el-table :data="lists" style="width: 100%" height="500" border @selection-change="handleSelectionChanges">
          <!-- <el-table-column type="selection" width="55"> </el-table-column> -->
          <el-table-column label="序号" width="50" type="index">
          </el-table-column>
          <el-table-column prop="address" label="图片" width="150">
            <template slot-scope="scope">
              <el-image style="width: 100px; height: 100px" :src="scope.row.img" :preview-src-list="[scope.row.img]">
              </el-image>
            </template>
          </el-table-column>
          <el-table-column prop="product_id" label="商品ID"> </el-table-column>
          <el-table-column prop="name" label="商品标题"> </el-table-column>
          <el-table-column prop="address" label="原因">
            <template slot-scope="scope">
              <div v-if="djnum.input <=
                scope.row.cell_info.product_click_cnt
                  .product_click_cnt_index_values.index_values.value
                  .value && djnum.radio == true
              ">
                点击次数:
                {{
                  scope.row.cell_info.product_click_cnt
                    .product_click_cnt_index_values.index_values.value.value
                }}
              </div>
              <div v-if="bgnum.input <=
                scope.row.cell_info.product_show_cnt
                  .product_show_cnt_index_values.index_values.value.value &&
                bgnum.radio == true
              ">
                曝光次数:
                {{
                  scope.row.cell_info.product_show_cnt
                    .product_show_cnt_index_values.index_values.value.value
                }}
              </div>
              <div v-if="radiosnum.input <= scope.row.sell_num &&
                radiosnum.radio == true
              ">
                总销量:{{ scope.row.sell_num }}
              </div>
              <div v-if="radiomoney.radio &&
                scope.row.market_price / 100 < radiomoney.input2 &&
                scope.row.market_price / 100 > radiomoney.input
              ">
                售价:{{ scope.row.market_price / 100 }}
              </div>
              <div v-if="stock_nums.radio &&
                scope.row.stock_num <= stock_nums.input2 &&
                scope.row.stock_num >= stock_nums.input
              ">
                库存:{{ scope.row.stock_num }}
              </div>
              <div v-if="radios">好评:{{ scope.row.comment_percent }}</div>
              <div v-if="scope.row.create_time >= ktime && radioss">
                铺货时间小于{{ typeNumber }}天
              </div>
            </template>
          </el-table-column>
        </el-table>
      </div>
    </el-dialog>
    <el-dialog title="" :visible.sync="errordatas" width="30%" :before-close="clos">
      <div style="height: 60px">
        <h3>{{ errordata.msg }}</h3>
        <div style="float: right">
          <el-button size="mini" type="primary" @click="goToUrl()">确定</el-button>
          <el-button size="mini" type="danger" @click="clos">取消</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog title="提示" :visible.sync="isStepDialog" width="30%">
      <div>
        <div class="font-size-16">
          1.如果您未打开或未登录电商罗盘请打开并登录电商罗盘，然后重新刷新该页面。
        </div>
        <div class="font-size-16 mt-10">
          2.如果您已经打开并登录电商罗盘还出现该弹窗，就需要您自行设置，<span style="color: red">
            否则将无法正常使用
          </span>
          。
        </div>
        <div class="font-size-16 mt-10">
          3.自动设置失败，需要您根据以下步骤自行设置，已经设置过的无需设置。
        </div>
        <div class="mt-10">
          <el-image style="width: 100px; height: 100px" class="mr-20" v-for="(item, index) in setprocessUrlList"
            :src="item" :key="index" :preview-src-list="setprocessUrlList"></el-image>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="isStepDialog = false">取 消</el-button>
        <el-button type="primary" @click="isStepDialog = false">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  getShopIdData,
  getShopUserPhone,
  productShopId,
  webpagehttp,
  tproduct,
  index,
} from '@/api/shopsApi'
import crossClass from '@/utils/cross-domain.js'
import stepOne from '@/assets/images/step-1.png'
import stepTwo from '@/assets/images/step-2.png'
import stepThree from '@/assets/images/step-3.png'
import stepfour from '@/assets/images/step-4.png'

const cityOptions = [
  {
    name: '商品ID',
    value: 'product_id',
  },
  {
    name: '商品信息',
    value: 'name',
  },
  {
    name: '价 格',
    value: 'jg',
  },
  {
    name: '总库存',
    value: 'stock_num',
  },
  {
    name: '总销量',
    value: 'sell_num',
  },
  {
    name: '创建时间',
    value: 'time',
  },
  {
    name: '点击次数',
    value: 'djcs',
  },
  {
    name: '点击人数',
    value: 'dj',
  },
  {
    name: '曝光次数',
    value: 'bgcs',
  },
  {
    name: '曝光人数',
    value: 'bg',
  },
]
export default {
  data() {
    return {
      contentss: '',
      setprocessUrlList: [stepOne, stepTwo, stepThree, stepfour],
      isStepDialog: false,
      iontime: '',
      lpradio: '商品管理列表',
      gllist: [],
      errordatas: false,
      errordata: {},
      date_type: '23',
      lods: false,
      disabled: false,
      selectedColumns: ['name'],
      // 点击
      djnum: {
        radio: false,
        input: '',
      },
      // 曝光
      bgnum: {
        radio: true,
        input: '10',
      },
      // 总库存位于
      stock_nums: {
        radio: false,
        input: '',
        input2: '',
      },
      //清理总销量
      radiosnum: {
        input: '',
        radio: false,
      },
      // 清理售价
      radiomoney: {
        radio: false,
        input: '',
        input2: '',
      },
      status: null,
      values: [],
      allProductslist: ['全部商品', '售卖中', '仓库中'],
      dialogVisibles: false,
      tableloading: false,
      checkAll: true,
      checkedCities: [
        'product_id',
        'name',
        'jg',
        'stock_num',
        'sell_num',
        'time',
        'djcs',
        'dj',
        'bgcs',
        'bg',
      ],
      cities: cityOptions,
      isIndeterminate: false,
      textarea: '',
      tableData: [],
      loading: false,
      loading2: false,
      loading3: false,
      loading4: false,
      btnName: '开始筛选',
      radio: 6,
      radio2: '售卖中',
      radios: false,
      rainput: '',
      radioss: false,
      typeNumber: '0',
      commodityAdminRadiolist: [
        {
          name: '近一天',
          label: 1,
        },
        {
          name: '近七天',
          label: 2,
        },
        {
          name: '近二十天',
          label: 3,
        },
        {
          name: '近三十天',
          label: 4,
        },
        {
          name: '近半年',
          label: 5,
        },
        {
          name: '全部',
          label: 6,
        },
      ],
      onlineretailers: [
        {
          name: '近一天',
          label: 1,
        },
        {
          name: '近七天',
          label: 2,
        },
        {
          name: '近二十天',
          label: 3,
        },
        {
          name: '近三十天',
          label: 4,
        },
      ],
      dialogVisible: false,
      list: [],
      multipleSelection: [],
      visible: false,
      start_time: '',
      end_time: '',
      lists: [],
      listsname: '',
      product_status: null,
      pagesall: '',
      titlelistlist: [],
      ktime: '',
      newArr: [],
      listType: 1,
      checkUrlOpen: [],
    }
  },
  mounted() {
    this.initSet()
    this.lods = true
    const dayjs = require('dayjs')
    this.start_time = dayjs()
      .subtract(30, 'day')
      .format('YYYY/MM/DD' + ' 00:00:00') //获取前30天时间
    this.end_time = dayjs()
      .subtract(1, 'day')
      .format('YYYY/MM/DD' + ' 00:00:00')
    const _ = setTimeout(() => {
      if (localStorage.getItem('Authorization')) {
        this.loading2 = false
        clearTimeout(_)
        const time = setTimeout(() => {
          index({}).then((res) => { })
          this.lods = false
          clearTimeout(time)
        }, 3000)
      } else {
        this.loading2 = false
        clearTimeout(_)
        this.lods = false
      }
    }, 1000)
  },
  methods: {
    async initSet() {
      const that = this
      const TipsFunc = (str, url) => {
        this.$confirm(str, '提示', {
          confirmButtonText: '前往打开',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then(() => {
            window.open(url)
            setTimeout(() => {
              that.$router.go(0)
            }, 3000)
          })
          .catch((err) => {
            setTimeout(() => {
              that.$router.go(0)
            }, 3000)
          })
      }
      const crossInstance = new crossClass()
      let checkUrlOpen = await crossInstance.checkUrlOpen([
        'https://compass.jinritemai.com/',
        'https://fxg.jinritemai.com/ffa',
      ])
      if (checkUrlOpen.code == 200) {
        that.checkUrlOpen = checkUrlOpen
        let compass = checkUrlOpen.data.find((item) => {
          return (
            item.url == 'https://compass.jinritemai.com/' && item.status == true
          )
        })
        let douDian = checkUrlOpen.data.find((item) => {
          return (
            item.url == 'https://fxg.jinritemai.com/ffa' && item.status == true
          )
        })
        if (!douDian) {
          const str = '使用该功能需要打开并登录抖店'
          const url = 'https://fxg.jinritemai.com/ffa'
          TipsFunc(str, url)
          return
        }
        if (!compass) {
          const str = '使用该功能需要打开并登录电商罗盘'
          const url =
            'https://compass.jinritemai.com/shop?btm_ppre=a6187.b01487.c0.d0&btm_pre=a6187.b7716.c0.d0&btm_show_id=d3e1e89f-f8b0-489e-bfe6-679bc7b6eae5&from_page=%2Fshop%2Fmerchandise-traffic'
          TipsFunc(str, url)
          return
        }

        crossInstance
          .sendMessageForPageFunc({
            id: compass.id,
            script: `fetch(
        'https://compass.jinritemai.com/compass_api/config_center/shop/modify_index?verifyFp=verify_ly8grujk_GafO9F4D_ga1o_48JO_BzkP_JCafpl5M4t1E&fp=verify_ly8grujk_GafO9F4D_ga1o_48JO_BzkP_JCafpl5M4t1E&msToken=0flT8cSw1FVJfgH2yG-df6XzKTxDCTyoDnX6k02Ud6fQyBAMZFCP5uVuM4Rad24deOYxXtJ-ohEBYdhNagVvxhGjHKze9j-X52jHp6pSyxDhoZ5LvwNcbw%3D%3D&a_bogus=mvWh%2Fmg6dDDTDDuD56oLfY3qIQbuY0xa0G3FMDZu-TB%2FQy39HMPX9exEIT0vb7gjNs%2FDIeDjy4hbO3xprQCJ0Zwf7WhO%2F2CZmy00cMlM59Tj-rineyUgrUkNmktISlc25k3WE%2Fi8wwIaSYukW9Fe-XdUPLZ7aNjk96EtO939lNE6HBV0',
        {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            index_selected_list: [
              'product_show_ucnt',
              'product_click_ucnt',
              'product_show_cnt',
              'product_click_cnt',
              'product_click_cnt_per_user',
              'product_potential_cus_click_ucnt',
              'product_old_cus_click_ucnt',
              'product_potential_cus_click_ucnt_rate',
              'product_old_cus_click_ucnt_rate',
              'prod_wish_ucnt',
              'click_add_to_cart_ucnt',
              'boost_pv',
              'product_click_ucnt_rate',
              'product_click_cnt_rate',
              'pay_converse_rate_ucnt',
              'pay_converse_cnt_rate',
              'product_show_pay_ucnt_rate',
              'product_show_pay_cnt_rate',
              'product_gpm',
              'pay_amt',
              'pay_ucnt',
              'pay_user_unit_price',
              'pay_cnt',
              'new_cus_pay_ucnt',
              'old_cus_pay_ucnt',
              'new_cus_pay_ucnt_rate',
              'old_cus_pay_ucnt_rate'
            ],
            scene_identity: 'shop_traffic_analysis_channel_product'
          })
        }
      )
        .then((res) => {
          return res.json()
        })
        .catch((err) => {})
        .then((res) => {
            window.postMessage({
                type_urs: 'wkyy-wtbg',
                data: res,
                type_page: 'pageMeat',
                method: 'send_message_for_page'
            })
        })`,
          })
          .then((res) => {
            if (res) {
              if (!res.code == 200 || !res.data) {
                this.isStepDialog = true
              }
            } else {
              crossInstance.closeListen()
            }
          })
          .catch((err) => {
            console.log(err, '11111')
          })
      }
    },
    lpalllist(val) {
      this.listType = val
      if (val == 1) {
        this.radio = 6
        this.getTimes(0, 5)
      } else {
        this.radio = 4
        this.getTimes(0, 3)
      }
    },
    clos() {
      this.errordatas = false
    },
    goToUrl() {
      this.errordatas = false
      window.open(this.errordata.url)
    },
    // 复制
    copy() {
      if (this.checkedCities.length > 0 && this.multipleSelection.length > 0) {
        let lists = []
        cityOptions.map((item, index) => {
          this.checkedCities.map((items, indexs) => {
            if (item.value == items) {
              lists.push(item)
            }
          })
        })
        let a = lists.map((item) => {
          return { [item.name]: item.value }
        })
        let b = {}
        for (let key in a) {
          if (a.hasOwnProperty(key)) {
            const obj = a[key]
            for (let prop in obj) {
              if (obj.hasOwnProperty(prop)) {
                // 将中文键作为新对象的键，值保持不变
                b[prop] = obj[prop]
                break // 假设每个对象只有一个属性需要转换
              }
            }
          }
        }
        import('./Export2Excel copy 2').then((excel) => {
          let headers = b
          let data = this.multipleSelection
          let finalData = excel.formatJson(headers, data)
          excel.export_json_to_excel({
            header: Object.keys(headers), //表头 必填
            data: finalData, //具体数据 必填
            filename: `清理无流量`, //非必填
            autoWidth: true, //非必填
            bookType: 'txt', //非必填
          })
        })
        this.$message({
          message: '复制成功',
          type: 'success',
        })
      } else {
        if (this.checkedCities.length == 0) {
          this.$message({
            message: '请选择一个字段',
            type: 'error',
          })
        } else if (this.multipleSelection.length == 0) {
          this.$message({
            message: '请选择数据',
            type: 'error',
          })
        }
      }
    },
    // CSV
    goCsv() {
      if (this.checkedCities.length > 0 && this.multipleSelection.length > 0) {
        let lists = []
        cityOptions.map((item, index) => {
          this.checkedCities.map((items, indexs) => {
            if (item.value == items) {
              lists.push(item)
            }
          })
        })
        let a = lists.map((item) => {
          return { [item.name]: item.value }
        })
        let b = {}
        for (let key in a) {
          if (a.hasOwnProperty(key)) {
            const obj = a[key]
            for (let prop in obj) {
              if (obj.hasOwnProperty(prop)) {
                b[prop] = obj[prop].toString()
                break // 假设每个对象只有一个属性需要转换
              }
            }
          }
        }
        this.multipleSelection.map((item, index) => {
          item.product_id = item.product_id.toString()
        })
        import('./Export2Excel').then((excel) => {
          let headers = b
          let data = this.multipleSelection
          let finalData = excel.formatJson(headers, data)
          excel.export_json_to_excel({
            header: Object.keys(headers), //表头 必填
            data: finalData, //具体数据 必填
            filename: `清理无流量`, //非必填
            autoWidth: true, //非必填
            bookType: 'csv', //非必填
          })
        })
      } else {
        if (this.checkedCities.length == 0) {
          this.$message({
            message: '请选择一个字段',
            type: 'error',
          })
        } else if (this.multipleSelection.length == 0) {
          this.$message({
            message: '请选择数据',
            type: 'error',
          })
        }
      }
    },
    // 文本
    goTxt() {
      if (this.checkedCities.length > 0 && this.multipleSelection.length > 0) {
        let lists = []
        cityOptions.map((item, index) => {
          this.checkedCities.map((items, indexs) => {
            if (item.value == items) {
              lists.push(item)
            }
          })
        })
        let a = lists.map((item) => {
          return { [item.name]: item.value }
        })
        let b = {}
        for (let key in a) {
          if (a.hasOwnProperty(key)) {
            const obj = a[key]
            for (let prop in obj) {
              if (obj.hasOwnProperty(prop)) {
                // 将中文键作为新对象的键，值保持不变
                b[prop] = obj[prop]
                break // 假设每个对象只有一个属性需要转换
              }
            }
          }
        }
        import('./Export2Excel copy').then((excel) => {
          let headers = b
          let data = this.multipleSelection
          let finalData = excel.formatJson(headers, data)
          excel.export_json_to_excel({
            header: Object.keys(headers), //表头 必填
            data: finalData, //具体数据 必填
            filename: `清理无流量`, //非必填
            autoWidth: true, //非必填
            bookType: 'txt', //非必填
          })
        })
      } else {
        if (this.checkedCities.length == 0) {
          this.$message({
            message: '请选择一个字段',
            type: 'error',
          })
        } else if (this.multipleSelection.length == 0) {
          this.$message({
            message: '请选择数据',
            type: 'error',
          })
        }
      }
    },
    // 导出
    Export() {
      if (this.checkedCities.length > 0 && this.multipleSelection.length > 0) {
        var lists = []
        cityOptions.map((item, index) => {
          this.checkedCities.map((items, indexs) => {
            if (item.value == items) {
              lists.push(item)
            }
          })
        })
        let a = lists.map((item) => {
          return { [item.name]: item.value }
        })
        var b = {}
        for (let key in a) {
          if (a.hasOwnProperty(key)) {
            const obj = a[key]
            for (let prop in obj) {
              if (obj.hasOwnProperty(prop)) {
                // 将中文键作为新对象的键，值保持不变
                b[prop] = obj[prop]
                break // 假设每个对象只有一个属性需要转换
              }
            }
          }
        }
        import('./Export2Excel').then((excel) => {
          let headers = b
          let data = this.multipleSelection
          let finalData = excel.formatJson(headers, data)
          excel.export_json_to_excel({
            header: Object.keys(headers), //表头 必填
            data: finalData, //具体数据 必填
            filename: `清理无流量`, //非必填
            autoWidth: true, //非必填
            bookType: 'xlsx', //非必填
          })
        })
      } else {
        if (this.checkedCities.length == 0) {
          this.$message({
            message: '请选择一个字段',
            type: 'error',
          })
        } else if (this.multipleSelection.length == 0) {
          this.$message({
            message: '请选择数据',
            type: 'error',
          })
        }
      }
    },
    // 商品管理
    titlelist() {
      if (this.gllist.length == 0) {
        tproduct({
          page: '0',
          pageSize: '20',
          business_type: '4',
          is_online: '1',
          not_for_sale_search_type: '1',
          appid: '1',
        })
          .then((res) => {
            this.lods = false
            let totalNum = res.total
            let ergodicNum = 0
            const isInteger = (obj) => {
              return obj % 1 === 0
            }
            if (totalNum <= 10) {
              ergodicNum = 0
            } else if (isInteger(totalNum / 20)) {
              ergodicNum = totalNum / 20
            } else {
              ergodicNum = Math.trunc(totalNum / 20) + 1
            }
            let z = []
            for (let i = 0; i < ergodicNum; i++) {
              z.push(i)
            }
            const promises = z.map((item, index) => {
              return tproduct({
                page: index,
                pageSize: '20',
                business_type: '4',
                is_online: '1',
                not_for_sale_search_type: '1',
                appid: '1',
              })
            })
            Promise.all(promises)
              .then((results) => {
                let a = []
                results.map((item) => {
                  item.data.map((i) => {
                    if (i.tab == '售卖中' || i.tab == '已下架') {
                      a.push(i)
                    }
                  })
                })
                this.gllist = a
                this.set()
              })
              .catch((error) => {
                if (error.msg.length > 0) {
                  this.$message.error(error.msg)
                }
                this.loading2 = false
                this.disabled = false
                this.tableloading = false
                this.lods = false
              })
          })
          .catch((error) => {
            if (error.msg.length > 0) {
              this.$message.error(error.msg)
            }
            this.loading2 = false
            this.disabled = false
            this.tableloading = false
            this.lods = false
          })
      } else {
        this.set()
      }
    },
    allProducts() {
      if (this.radio2 == '全部商品') {
        this.product_status = null
        this.status = null
      }
      if (this.radio2 == '售卖中') {
        this.product_status = 1
        this.status = 0
      }
      if (this.radio2 == '仓库中') {
        this.product_status = 2
        this.status = 1
      }
    },
    bt1Vis() {
      this.values = this.textarea.trim().split('\n')
      var newArr = []
      for (let i = 0; i < this.values.length; i++) {
        newArr.indexOf(this.values[i]) === -1
          ? newArr.push(this.values[i])
          : newArr
      }
      this.list = []
      this.newArr = newArr
      if (this.gllist.length == 0) {
        this.titlelist()
      } else {
        this.set()
      }
      this.dialogVisible = false
    },
    getTimes(item, index) {
      if (this.listType == 1) {
        const dayjs = require('dayjs')
        this.iontime = ''
        let ftime = ''
        if (index == 0) {
          ftime = dayjs()
            .subtract(1, 'day')
            .format('YYYY/MM/DD' + ' 00:00:00')
          this.iontime = new Date(ftime).getTime() / 1000
        } else if (index == 1) {
          ftime = dayjs()
            .subtract(7, 'day')
            .format('YYYY/MM/DD' + ' 00:00:00')
          this.iontime = new Date(ftime).getTime() / 1000
        } else if (index == 2) {
          ftime = dayjs()
            .subtract(20, 'day')
            .format('YYYY/MM/DD' + ' 00:00:00')
          this.iontime = new Date(ftime).getTime() / 1000
        } else if (index == 3) {
          ftime = dayjs()
            .subtract(30, 'day')
            .format('YYYY/MM/DD' + ' 00:00:00')
          this.iontime = new Date(ftime).getTime() / 1000
        } else if (index == 4) {
          ftime = dayjs()
            .subtract(180, 'day')
            .format('YYYY/MM/DD' + ' 00:00:00')
          this.iontime = new Date(ftime).getTime() / 1000
        } else if (index == 5) {
          ftime = ''
          this.iontime = ''
        }
      } else if (this.listType == 2) {
        let td = this.$moment()
          .subtract(1, 'days')
          .startOf('day')
          .format('YYYY/MM/DD HH:mm:ss')
        let after = null
        if (index == 0) {
          after = this.$moment()
            .subtract(1, 'days')
            .startOf('day')
            .format('YYYY/MM/DD HH:mm:ss')
          this.date_type = '20'
        } else if (index == 1) {
          after = this.$moment()
            .subtract(1, 'weeks')
            .startOf('day')
            .format('YYYY/MM/DD HH:mm:ss')
          this.date_type = '21'
        } else if (index == 2) {
          after = this.$moment()
            .subtract(20, 'days')
            .startOf('day')
            .format('YYYY/MM/DD HH:mm:ss')
          this.date_type = '23'
        } else if (index == 3) {
          after = this.$moment()
            .subtract(30, 'days')
            .startOf('day')
            .format('YYYY/MM/DD HH:mm:ss')
          this.date_type = '23'
        }
        this.start_time = after
        this.end_time = td
      }
    },
    bt4() {
      var slist = []
      this.multipleSelection.map((item) => {
        if (item.status != 2) {
          slist.push(item)
        }
      })
      if (this.multipleSelection.length > 0) {
        this.tableData.map((item) => {
          this.multipleSelection.map((i) => {
            if (item.product_id == i.product_id) {
              item.alerts = '已删除'
            }
          })
        })
        this.tableData.push({})
        this.tableData.pop()
        if (slist.length > 0) {
          const promises = slist.map((item) => {
            return productShopId({
              product_id: item.product_id,
              delete_forever: false,
              shop_id: localStorage.getItem('shop_id'),
            })
          })
          Promise.all(promises)
            .then((results) => {
              this.gllist = []
            })
            .catch((error) => { })
        }
        this.$message({
          message: '执行完毕',
          type: 'success',
        })
      } else {
        this.$message.error('请选择数据')
      }
    },
    bt3() {
      var slist = []
      this.multipleSelection.map((item) => {
        if (item.status == 0) {
          slist.push(item)
        }
      })
      if (this.multipleSelection.length > 0) {
        this.tableData.map((item) => {
          this.multipleSelection.map((i) => {
            if (item.product_id == i.product_id) {
              if (item.alerts == '已删除') {
              } else {
                item.alerts = '已下架'
              }
            }
          })
        })
        this.tableData.push({})
        this.tableData.pop()
        if (slist.length > 0) {
          const promises = slist.map((item) => {
            return getShopIdData({
              product_id: item.product_id,
              shop_id: localStorage.getItem('shop_id'),
            })
          })
          Promise.all(promises)
            .then((results) => {
              if (results.data.code == '40004') {
                this.$message.error(results.data.sub_msg)
              }
            })
            .catch((error) => { })
          this.gllist = []
        } else {
        }
        this.$message({
          message: '执行完毕',
          type: 'success',
        })
      } else {
        this.$message.error('请选择数据')
      }
    },
    handleSelectionChange(val) {
      this.multipleSelection = val
    },
    handleSelectionChanges(val) { },
    set() {
      this.loading2 = true
      this.disabled = true
      this.tableloading = true
      this.list = []
      const dayjs = require('dayjs')
      let date_type
      if (this.listType == 2) {
        date_type = this.date_type
      } else {
        date_type = null
      }
      webpagehttp({
        date_type: date_type || 23,
        product_status: this.product_status || '',
        end_date: this.end_time,
        begin_date: this.start_time,
        activity_id: '',
        is_activity: 'false',
        category_code: '',
        channel: 'all',
        pattern: '2',
        search_word: '',
        is_asc: 'false',
        page_no: '1',
        page_size: '10',
        _lid: '404970977736',
      })
        .then((res) => {
          let totalNum = res.page_result.total
          let ergodicNum = 0
          const isInteger = (obj) => {
            return obj % 1 === 0
          }
          if (totalNum <= 10) {
            ergodicNum = 1
          } else if (isInteger(totalNum / 10)) {
            ergodicNum = totalNum / 10
          } else {
            ergodicNum = Math.trunc(totalNum / 10) + 1
          }
          let z = []
          for (let i = 0; i < ergodicNum; i++) {
            z.push(i)
          }
          const promises = z.map((item) => {
            return webpagehttp({
              product_status: this.product_status || '',
              date_type: date_type || 23,
              end_date: this.end_time,
              begin_date: this.start_time,
              activity_id: '',
              is_activity: 'false',
              category_code: '',
              channel: 'all',
              pattern: '2',
              search_word: '',
              is_asc: 'false',
              page_no: String(item + 1),
              page_size: '10',
              _lid: '404970977736',
            })
          })
          Promise.all(promises)
            .then((res) => {
              if (res.length > 0) {
                let alist = []
                res.map((item, index) => {
                  !!item.data && alist.push(item.data)
                })
                let lo = []
                alist.map((item) => {
                  item.map((i, is) => {
                    lo.push(i)
                  })
                })
                if (lo.length == 0) {
                  this.loading2 = false
                  this.disabled = false
                  this.tableloading = false
                  return
                }
                let chunkSize = 20 // 每个子数组的大小
                // 使用reduce方法将数组分割成多个子数组，并收集每个子数组中的产品ID
                let idlists = lo.reduce((result, item, index) => {
                  const chunkIndex = Math.floor(index / chunkSize) // 计算当前元素应该属于哪个子数组
                  // 如果结果数组中没有对应的子数组，则创建一个新的空数组
                  if (!result[chunkIndex]) {
                    result[chunkIndex] = []
                  }
                  // 将产品ID添加到对应的子数组中
                  result[chunkIndex].push(
                    item.cell_info.product.product_id_value.value.value_str
                  )
                  // 返回结果数组
                  return result
                }, []) // 初始化结果数组为空数组

                const promises = idlists.map((item, index) => {
                  let a = []
                  a.push(item)
                  a.join(',')
                  return tproduct({
                    page: '0',
                    pageSize: '20',
                    id_name_code: a,
                  })
                })
                Promise.all(promises)
                  .then((results) => {
                    try {
                      let d = []
                      results.map((item) => {
                        item.data.map((i) => {
                          d.push(i)
                        })
                      })

                      results.map((i) => {
                        i.data.map((j) => {
                          this.titlelistlist.push({
                            ids: j.product_id,
                            stock_num: j.stock_num,
                            comment_percent: j.comment_percent,
                            draft_time: j.draft_time,
                          })
                        })
                      })
                    } catch (e) {
                      console.log(e, 'eeeeeeeeeeeeee')
                    }
                  })
                  .catch((err) => {
                    console.log(err)
                  })
                if (lo.length > 0) {
                  lo.map((item) => {
                    try {
                      this.list.push({
                        id: item.cell_info.product.product_id_value.value
                          .value_str,
                        number:
                          item.cell_info.product_show_ucnt
                            .product_show_ucnt_index_values.index_values.value
                            .value,
                        data: item,
                      })
                    } catch (error) {
                      console.log(error)
                    }
                  })
                  this.sets()
                }
              } else {
                this.loading2 = false
                this.disabled = false
                this.tableloading = false
              }
            })
            .catch((error) => {
              console.log(error, '111111111111')
            })
        })
        .catch((error) => {
          console.log('error', error)
          this.$message({
            type: 'error',
            message: '请检查抖店登录账号与电商罗盘登录账号是否一致',
            duration: 5000,
          })
          if ((error.msg = '子账号无权限')) {
          } else {
            localStorage.setItem('loginstatus', false)
          }
          this.loading2 = false
          this.disabled = false
          this.tableloading = false
        })
    },

    sets() {
      this.tableloading = true
      let b = []
      let v = []
      this.lists = []
      this.list.map((item) => {
        b.push(item.id)
        v.push(item)
      })
      // 保留铺货时间
      let time1 = ''
      if (this.radioss) {
        if (this.typeNumber.length > 0) {
          const dayjs = require('dayjs')
          let create_time = dayjs()
            .subtract(Number(this.typeNumber) + 1, 'day')
            .format('YYYY/MM/DD' + ' 00:00:00')
          time1 = new Date(create_time).getTime() / 1000
          this.ktime = new Date(create_time).getTime() / 1000
        }
      }
      const chunkSize = 100 // 每个子数组包含的对象数量
      let chunkedArray = []
      for (let i = 0; i < b.length; i += chunkSize) {
        const end = Math.min(i + chunkSize, b.length)
        chunkedArray.push(b.slice(i, end))
      }
      const promises = chunkedArray.map((item, index) => {
        return getShopUserPhone({
          product_id: item,
          size: 100,
          page: 1,
          shop_id: localStorage.getItem('shop_id'),
        })
      })
      Promise.all(promises)
        .then((results) => {
          this.gllist.forEach((item) => {
            if (String(item.create_time).length == 10) {
            } else {
              item.create_time = new Date(item.create_time).getTime() / 1000
              item.cell_info = {
                product_click_ucnt: {
                  product_click_ucnt_index_values: {
                    index_values: {
                      value: {
                        value: 0,
                      },
                    },
                  },
                },
                product_click_cnt: {
                  product_click_cnt_index_values: {
                    index_values: {
                      value: {
                        value: 0,
                      },
                    },
                  },
                },
                product_show_ucnt: {
                  product_show_ucnt_index_values: {
                    index_values: {
                      value: {
                        value: 0,
                      },
                    },
                  },
                },
                product_show_cnt: {
                  product_show_cnt_index_values: {
                    index_values: {
                      value: {
                        value: 0,
                      },
                    },
                  },
                },
              }
            }
          })
          let res = []
          if (results[0].data.data) {
            results.map((item) => {
              item.data.data.data.map((i) => {
                res.push(i)
              })
            })
            // 创建一个 Set 来存储已经在 res 中的 product_id
            const resProductIds = new Set(res.map((item) => item.product_id))
            // 使用 filter 来过滤 this.gllist，只保留那些 product_id 不在 resProductIds 中的 item
            const filteredList = this.gllist.filter(
              (item) => !resProductIds.has(item.product_id)
            )
            // 如果需要，将 filteredList 合并到 res 中
            if (this.lpradio == '商品管理列表') {
              // console.log('商品管理列表')
              res.push(...filteredList)
            }
            // 统计时间
            if (String(this.iontime).length > 0 && this.listType == 1) {
              // console.log('统计时间')
              res = res.filter((item) => {
                return item.create_time > this.iontime
              })
            }
            let sstatus = null
            if (this.radio2 == '售卖中') {
              sstatus = 0
            } else if (this.radio2 == '仓库中') {
              sstatus = 1
            }
            let data = []
            if (this.newArr.length > 0) {
              res.map((item) => {
                this.newArr.map((i) => {
                  if (item.product_id == i) {
                    if (item.status == sstatus || sstatus == null) {
                      data.push(item)
                    }
                  }
                })
              })
            } else {
              if (sstatus == null) {
                // console.log('全部商品数据处理')
                data = res
              } else {
                // console.log('售卖中或仓库中数据处理')
                res.forEach((item) => {
                  if (item.status == sstatus) {
                    data.push(item)
                  }
                })
              }
            }
            data.map((item) => {
              let sign = JSON.parse(JSON.stringify(this.titlelistlist)).find(
                (findItem) => {
                  return item.product_id == findItem.ids
                }
              )
              if (sign) {
                item.stock_num = sign.stock_num
                item.comment_percent = sign.comment_percent
              } else {
                item.stock_num = 0
                item.comment_percent = 0
              }
            })
            if (data.length > 0) {
              data.map((item) => {
                v.map((item2) => {
                  if (item.product_id == item2.id) {
                    item.cell_info = item2.data.cell_info
                    item.number = item2.number
                  } else {
                  }
                })
              })
              let datas = []
              // 加载
              data.map((item, index) => {
                item.Journal = ''
                datas.push(item)
              })
              // 时间
              if (this.radioss) {
                if (this.typeNumber > 0) {
                  datas = datas.filter((item) => {
                    return Number(item.create_time) <= Number(time1)
                  })
                  this.lists = this.lists.filter((item) => {
                    return Number(item.create_time) <= Number(time1)
                  })
                } else {
                  this.$message({
                    type: 'error',
                    message: '请填写保留铺货时间，否则将无法正常筛选商品。',
                    duration: 5000,
                  })
                }
              }
              let start_Mon =
                Number(String(this.radiomoney.input)).toFixed(2) * 100
              let end_Mon =
                Number(String(this.radiomoney.input2)).toFixed(2) * 100
              if (this.radiomoney.radio === true) {
                if (start_Mon != 0 && end_Mon != 0) {
                  datas = datas.filter((item) => {
                    return (
                      item.market_price >= start_Mon &&
                      item.market_price <= end_Mon
                    )
                  })
                  this.lists = this.lists.filter((item) => {
                    return (
                      item.market_price >= start_Mon &&
                      item.market_price <= end_Mon
                    )
                  })
                } else {
                  this.$message({
                    message: '请填写完整的售价区间，否则将无法正常筛选商品。',
                    type: 'error',
                    duration: 5000,
                  })
                }
              }
              // 清理总销量
              if (this.radiosnum.radio == true) {
                if (this.radiosnum.input.length > 0) {
                  datas = datas.filter((item) => {
                    return item.sell_num <= this.radiosnum.input
                  })
                  this.lists = this.lists.filter((item) => {
                    return item.sell_num <= this.radiosnum.input
                  })
                } else {
                  this.$message({
                    type: 'error',
                    message: '请填写完整的总销量区间，否则将无法正常筛选商品。',
                    duration: 5000,
                  })
                }
              }
              // 总库存位于
              if (this.stock_nums.radio == true) {
                if (
                  this.stock_nums.input.length > 0 &&
                  this.stock_nums.input2.length > 0
                ) {
                  datas = datas.filter((item) => {
                    return (
                      item.stock_num >= this.stock_nums.input &&
                      item.stock_num <= this.stock_nums.input2
                    )
                  })
                  this.lists = this.lists.filter(
                    (item) =>
                      item.stock_num >= this.stock_nums.input &&
                      item.stock_num <= this.stock_nums.input2
                  )
                } else {
                  this.$message({
                    type: 'error',
                    message: '请填写完整的总库存区间，否则将无法正常筛选商品。',
                    duration: 5000,
                  })
                }
              }
              // 清理曝光次数
              if (this.bgnum.radio == true) {
                if (this.bgnum.input.length > 0) {
                  datas = datas.filter(
                    (item) =>
                      item.cell_info.product_show_cnt
                        .product_show_cnt_index_values.index_values.value
                        .value <= this.bgnum.input
                  )
                  this.lists = this.lists.filter(
                    (item) =>
                      item.cell_info.product_show_cnt
                        .product_show_cnt_index_values.index_values.value
                        .value <= this.bgnum.input
                  )
                } else {
                  this.$message({
                    type: 'error',
                    message:
                      '请填写完整的曝光次数区间，否则将无法正常筛选商品。',
                    duration: 5000,
                  })
                }
              }
              // 清理点击次数
              if (this.djnum.radio == true) {
                if (this.djnum.input.length > 0) {
                  datas = datas.filter((item) => {
                    return (
                      Number(
                        item.cell_info.product_click_cnt
                          .product_click_cnt_index_values.index_values.value
                          .value
                      ) <= Number(this.djnum.input)
                    )
                  })
                  this.lists = this.lists.filter((item) => {
                    return (
                      Number(
                        item.cell_info.product_click_cnt
                          .product_click_cnt_index_values.index_values.value
                          .value
                      ) <= Number(this.djnum.input)
                    )
                  })
                } else {
                  this.$message({
                    type: 'error',
                    message:
                      '请填写完整的点击次数区间，否则将无法正常筛选商品。',
                    duration: 5000,
                  })
                }
              }
              // 好评
              if (this.radios == true) {
                if (this.rainput.length > 0) {
                  datas = datas.filter(
                    (item) => item.comment_percent <= this.rainput
                  )
                  this.lists = this.lists.filter(
                    (item) => item.comment_percent <= this.rainput
                  )
                } else {
                  this.$message({
                    type: 'error',
                    message: '请填写完整的好评率区间，否则将无法正常筛选商品。',
                    duration: 5000,
                  })
                }
              }
              if (
                this.radiomoney.radio == true ||
                this.radiosnum.radio == true ||
                this.stock_nums.radio == true ||
                this.bgnum.radio == true ||
                this.djnum.radio == true ||
                this.radios == true ||
                this.radioss == true
              ) {
                this.lists = data.filter((item) => {
                  return !datas.some(
                    (items) => items.product_id === item.product_id
                  )
                })
                datas.map((item, index) => {
                  item.jg = '￥' + (item.market_price / 100).toFixed(2)
                  item.dj =
                    item.cell_info.product_click_ucnt.product_click_ucnt_index_values.index_values.value.value
                  item.djcs =
                    item.cell_info.product_click_cnt.product_click_cnt_index_values.index_values.value.value
                  item.bg =
                    item.cell_info.product_show_ucnt.product_show_ucnt_index_values.index_values.value.value
                  item.bgcs =
                    item.cell_info.product_show_cnt.product_show_cnt_index_values.index_values.value.value
                  item.time = this.$moment(item.create_time * 1000).format(
                    'YYYY-MM-DD HH:mm:ss'
                  )
                })

                this.tableData = datas
                this.tableloading = false
                this.loading2 = false
                this.disabled = false
              } else {
                datas.map((item, index) => {
                  this.lists.push(item)
                })
                this.tableData = []
                this.tableloading = false
                this.loading2 = false
                this.disabled = false
              }
            } else {
              this.lists = []
              this.list = []
              this.tableData = []
              this.loading2 = false
              this.disabled = false
              this.tableloading = false
            }
          } else {
            this.loading2 = false
            this.disabled = false
            this.tableloading = false
            this.$message.error('请求出错')
          }
          this.newArr = []
        })
        .catch((error) => {
          let { data, code } = error
          code == 0 &&
            data.code == 4390 &&
            this.$confirm(data.msg, '提示', {
              confirmButtonText: '前往订购',
              cancelButtonText: '取消',
              type: 'warning',
            })
              .then((res) => {
                window.open(data.url)
              })
              .catch((err) => { })
          this.loading2 = false
          this.disabled = false
          this.tableloading = false
        })
    },
    handleCloses(done) {
      done()
    },
    bt2() {
      if (localStorage.getItem('Csrf') != null) {
        const WT_requestcp = window.WT_request_wk
        this.loading2 = true
        this.disabled = true
        this.tableloading = true
        const _ = setTimeout(() => {
          this.lists = []
          this.tableData = []
          if (WT_requestcp) {
            if (localStorage.getItem('Authorization') != null) {
              if (localStorage.getItem('Authorization').length > 0) {
                this.loading2 = true
                if (this.titlelistlist.length > 0) {
                  this.titlelist()
                } else {
                  setTimeout(() => {
                    this.titlelist()
                  }, 2000)
                }
              }
            } else {
              this.loading2 = false
              this.$message.error('请先登录罗盘')
              localStorage.setItem('loginstatus', false)
            }
          } else {
            this.loading2 = false
            this.disabled = false
            this.tableloading = false
            this.$confirm('使用该功能需要安装插件', '提示', {
              confirmButtonText: '安装插件',
              cancelButtonText: '取消',
              type: 'warning',
            })
              .then((res) => {
                window.open('https://doulingyang.cn/')
              })
              .catch((err) => { })
            return
          }
          clearTimeout(_)
        }, 2000)
      } else {
        window.location.href = window.location.href
      }
    },
    bt1() {
      const WT_requestcp = window.WT_request_wk
      if (WT_requestcp) {
        this.dialogVisible = true
      } else {
        this.$confirm('使用该功能需要安装插件', '提示', {
          confirmButtonText: '安装插件',
          cancelButtonText: '取消',
          type: 'warning',
        })
          .then((res) => {
            window.open('https://doulingyang.cn/')
          })
          .catch((err) => { })
        return
      }
    },
    handleClose(done) {
      this.textarea = ''
      this.values = []
      this.dialogVisible = false
      done()
    },
    handleCheckAllChange(val) {
      let a = []
      cityOptions.map((item) => {
        a.push(item.value)
      })
      this.checkedCities = val ? a : []
      this.isIndeterminate = false
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length
      this.checkAll = checkedCount === this.cities.length
      this.isIndeterminate =
        checkedCount > 0 && checkedCount < this.cities.length
    },
  },
}
</script>
<style>
.el-checkbox__input.is-checked+.el-checkbox__label {
  color: #000000;
}

input {
  border: 1px solid #b3b3b3;
}

textarea:focus {
  border-color: #b3b3b3;
  /* 设置获取焦点时的边框颜色 */
  outline: none;
  /* 移除默认的轮廓 */
}

textarea {
  border: 1px solid #b3b3b3;
}
</style>
